package de.hibernate.example;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class EmployeeCourseId implements Serializable {

	private Employee employee;
	private Course course;
	
	@ManyToOne
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	
	@ManyToOne
	public Course getCourse() {
		return course;
	}
	public void setCourse(Course course) {
		this.course = course;
	}
	
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        EmployeeCourseId that = (EmployeeCourseId) o;
 
        if (employee != null ? !employee.equals(that.employee) : that.employee != null) return false;
        if (course != null ? !course.equals(that.course) : that.course != null)
            return false;
 
        return true;
    }
 
    public int hashCode() {
        int result;
        result = (employee != null ? employee.hashCode() : 0);
        result = 31 * result + (course != null ? course.hashCode() : 0);
        return result;
    }
	
}
